/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bookstore.service;

import bookstore.dao.BsBookDao;
import bookstore.idao.IBookDao;
import bookstore.iservice.IBookService;
import bookstore.model.Book;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class BookService implements IBookService {

    private IBookDao bookDao = new BsBookDao();

    @Override
    public void setBookDao(IBookDao bookDao) {
        this.bookDao = bookDao;
    }
    @Override
    public void updateBook(Book book)
    {
        bookDao.updateBook(book);
    }
    @Override
    public void addBook(Book book) {
        try{
          bookDao.insert(book);
          System.out.println("sdsdsdsd");
        }catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    @Override
    public void editBook(Book book) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void deleteBook(Integer id) {
        this.bookDao.delete(id);
    }

    @Override
    public Book findBookById(Integer id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public List<Book> findBooksByPage(Integer categoryId, String name, Integer pageSize, Integer pageNo) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
     @Override
    public List<Book> findByCatId(Integer catId,Integer pageNo, Integer pageSize)
    {
        return bookDao.findByCatId(catId,pageNo,pageSize);
    }
    @Override
    public Integer findCount(Integer categoryId, String name) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    @Override
    public List<Book>findAllBook(Integer pageNo, Integer pageSize)
    {
        return bookDao.findAll(pageNo, pageSize);
    }
}
